﻿namespace RL
{
    using System;
    using System.ComponentModel;
    using System.Drawing.Design;
    using System.Windows.Forms.Design;

    public class MultiLineStringEditor : UITypeEditor
    {
        private IWindowsFormsEditorService service;

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            MultiLineString inputValue = new MultiLineString();
            if (((context != null) & (context.Instance != null)) & (provider != null))
            {
                this.service = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService));
                if (this.service != null)
                {
                    inputValue = (MultiLineString) value;
                    fEditorLongString.Edit(ref inputValue, "Edit " + context.PropertyDescriptor.Name);
                }
            }
            return inputValue;
        }

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            if ((context != null) & (context.Instance != null))
            {
                return UITypeEditorEditStyle.Modal;
            }
            return base.GetEditStyle(context);
        }
    }
}

